/**
 * @file button_callback.c
 * @author your name (you@domain.com)
 * @brief
 * @version 0.1
 * @date 2024-04-04
 *
 * @copyright Copyright (c) 2024
 *
 */
#include "button_callback.h"
#include "spi.h"
#include "usart.h"
struct Button btn1;
struct Button btn2;

/**
 * @brief 读取GPIO
 *
 * @param button_id
 * @return uint8_t
 */
uint8_t read_button_GPIO(uint8_t button_id)
{
    // you can share the GPIO read function with multiple Buttons
    switch (button_id)
    {
    case btn1_id:
        return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin);
    case btn2_id:
        // return HAL_GPIO_ReadPin(B2_GPIO_Port, B2_Pin);
    default:
        return 0;
    }
}

/**
 * @brief
 *
 * @param btn
 */
void BTN1_SINGLE_Click_Handler(void *btn)
{
    u1_printf("KEY0 single click\r\n");
}

void BTN1_PRESS_Down_Handler(void *btn)
{
    u1_printf("KEY0 single press down\r\n");

    // 开启SPI主机和从机数据通信
    HAL_SPI_TransmitReceive_IT(&hspi1, spi1_wbuff, spi1_rbuff, 10); // 主机发送数据
}